<?php
use DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs;
use App\Models\Category;
use App\Models\Content;

// 首页
Breadcrumbs::register('home', function ($breadcrumbs) {
    $breadcrumbs->push('首页', route('home'));
});

// 栏目页
Breadcrumbs::register('category', function ($breadcrumbs, $id) {
    $category = Category::findOrFail($id);
    $breadcrumbs->parent('home');
    $breadcrumbs->push($category->name, route('category', $id));
});

// 详细页
Breadcrumbs::register('detail', function ($breadcrumbs, $content) {
    $breadcrumbs->parent('category', $content->cid);
    $breadcrumbs->push($content->title, route('detail', $content->id));
});
